Skip to content

React Eval#21

Open
JoeCarnahan42 wants to merge 9 commits into
projectshft:mainfrom
JoeCarnahan42:main
Open

React Eval#21
JoeCarnahan42 wants to merge 9 commits into
projectshft:mainfrom
JoeCarnahan42:main

Conversation

@JoeCarnahan42
Copy link
Copy Markdown

No description provided.

Comment thread app/contacts/new/page.js Outdated
<form className="text-center p-3 mx-auto border rounded w-25 p-3">
<label><u>Name</u></label>
<br />
<input onChange={enableSubmit} required ref={nameInput} className="input-group-text m-auto" type="text" />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DRY, you can use JS helper methods to make this efficient

Comment thread app/contacts/page.js Outdated
const [search, setSearch] = useState(Data.all())
const searchCon = (e) => {
const normData = e.target.value.toLowerCase()
if (e.target.value === '') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value needs to be trimmed

Comment thread app/Data/page.js
@@ -0,0 +1,52 @@
const Data = {
contacts: [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference between this and get all contacts?

Comment thread app/Data/page.js Outdated
"phone_number": "+1-555-567-8901"
}
],
all: function () {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are already exposing all the contacts

Comment thread app/contacts/contact/page.js Outdated
export default function Contact(prop) {
const id = JSON.parse(prop.searchParams.id)

const contact = Data.contacts.find((c) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you are not using the GET you created?

Comment thread app/contacts/contact/page.js Outdated
const id = JSON.parse(prop.searchParams.id)

const contact = Data.contacts.find((c) => {
return c.id === id
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens when no contact is found? you will have errors

Comment thread app/contacts/new/page.js Outdated
Comment on lines +17 to +19



Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty spaces

Comment thread app/contacts/new/page.js Outdated

const addCon = (e) => {
e.preventDefault()
console.log('Adding...')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not push console logs that have no purpose

Comment thread app/contacts/new/page.js Outdated

const enableSubmit = () => {

const isValidUrl = (string) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be an util outside of the function

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is irrelevant when using type="url" in your input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants